<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Topclass {

    var $CI;
    var $appsetingarray;

    public function __construct() {
        $this->CI = & get_instance();
        $this->CI->load->helper('url');
        //   include "top/TopSdk.php";
        $this->CI->load->library('top/top/TopClient');
        $this->CI->load->library('top/top/RequestCheckUtil');
        $this->CI->config->load('topapiconfig');
        // $this->appsetingarray = $this->CI->config->item('new_app'); //测试评论墙
        $this->appsetingarray = $this->CI->config->item('top_commentwall_setting');
        // Do something with $params
    }

    public function get_topobj($classname) {//获得top的初始化对象，传入类名称
        $apiurl = "top/top/request/{$classname}";
        $this->CI->load->library($apiurl);
        $c = new TopClient;
        $appsetingarray = $this->appsetingarray;

        $c->appkey = $appsetingarray["behidend"]["appkey"]; //"21124740"
        $c->secretKey = $appsetingarray["behidend"]["appsecck"]; //"d6a8581eac74eb1fc5ad73bb846b3d53"

        return $c;
    }
	
	
	
/*	
	
	//初始化前台top对象
	public function get_topobj_front($classname) {//获得top的初始化对象，传入类名称
        $apiurl = "top/top/request/{$classname}";
        $this->CI->load->library($apiurl);
        $c = new TopClient;
        $appsetingarray = $this->appsetingarray;

        $c->appkey = $appsetingarray["front"]["appkey"]; //"21124740"
        $c->secretKey = $appsetingarray["front"]["appsecck"]; //"d6a8581eac74eb1fc5ad73bb846b3d53"

        return $c;
    }
	
	public function api_TraderatesGetRequest_front($classname, $sessionKey = null,$setPageNo=1,$setPageSize=20) {//获取一段时间的评论
        $c = $this->get_topobj_front($classname);
        $req = new $classname;
        $req->setFields("num_iid ,rated_nick,nick,created,item_title,item_price,content");
        $req->setRateType("get");
        $req->setRole("buyer");
		$req->setResult("good");
		$req->setPageNo($setPageNo);
		$req->setPageSize($setPageSize);
        return $resp = $c->execute($req, $sessionKey);
    }
	
	
	*/
	
	
	
	
	
	

    public function api_getSellercatsListGetRequest($classname, $nickname, $sessionkey = null) {//获得店铺分类api封装
        $c = $this->get_topobj($classname);
        $req = new $classname;
        $req->setNick($nickname);
        $resp = $c->execute($req);
        return $resp;
    }

    public function api_getShopGetRequest($classname, $nickname) {//获得shopidapi封装
        $c = $this->get_topobj($classname);
        $req = new $classname;
        $req->setFields("sid,cid,title,nick,desc,bulletin,pic_path,created,modified");
        $req->setNick($nickname);
        return $resp = $c->execute($req);
    }

    public function api_SellercenterSubusersGetRequest($classname, $nickname, $sessionkey = null) {//获得子帐号
        $c = $this->get_topobj($classname);
        $req = new $classname;
        $req->setNick($nickname);
        return $resp = $c->execute($req, $sessionkey);
    }

    public function api_getSellercenterRolesGetRequest($classname, $nickname, $sessionKey = null) {//获取帐号的子角色
        //收入大号获取下面包含的角色
        $c = $this->get_topobj($classname);
        $req = new $classname;
        $req->setNick($nickname);
        return $resp = $c->execute($req, $sessionKey);
    }

    public function api_getSellercenterRolemembersGetRequest($classname, $roleid, $sessionKey = null) {//
        //属于角色roleid获取下面所包含的客服昵等信息
        $c = $this->get_topobj($classname);
        $req = new $classname;
        $req->setRoleId($roleid);
        return $resp = $c->execute($req, $sessionKey);
    }

    public function api_getUserGetRequest($classname, $nickname, $sessionKey = null) {

        $c = $this->get_topobj($classname);
        $req = new $classname;
        $req->setFields("user_id,nick,sex,seller_credit,type,has_more_pic,item_img_num,item_img_size,prop_img_num,prop_img_size,auto_repost,promoted_type,status,alipay_bind,consumer_protection,avatar,liangpin,sign_food_seller_promise,has_shop,is_lightning_consignment,has_sub_stock,is_golden_seller,vip_info,magazine_subscribe,vertical_market,online_gaming");
        return $resp = $c->execute($req, $sessionKey);
    }

    public function api_TradesSoldGetRequest($classname, $sessionKey = null) {//获取近期卖家交易记录api
        $c = $this->get_topobj($classname);
        $req = new $classname;
        $req->setFields("seller_nick,buyer_nick,title,type,created,sid,tid,seller_rate,buyer_rate,status,payment,discount_fee,adjust_fee,post_fee,total_fee,pay_time,end_time,modified,consign_time,buyer_obtain_point_fee,point_fee,real_point_fee,received_payment,commission_fee,pic_path,num_iid,num_iid,num,price,cod_fee,cod_status,shipping_type,receiver_name,receiver_state,receiver_city,receiver_district,receiver_address,receiver_zip,receiver_mobile,receiver_phone,orders.title,orders.pic_path,orders.price,orders.num,orders.iid,orders.num_iid,orders.sku_id,orders.refund_status,orders.status,orders.oid,orders.total_fee,orders.payment,orders.discount_fee,orders.adjust_fee,orders.sku_properties_name,orders.item_meal_name,orders.buyer_rate,orders.seller_rate,orders.outer_iid,orders.outer_sku_id,orders.refund_id,orders.seller_type");
		return $resp = $c->execute($req, $sessionKey);
    }

    public function api_TraderatesGetRequest($classname, $sessionKey = null,$setPageNo=1,$setPageSize=20) {//获取一段时间的评论
        $c = $this->get_topobj($classname);
        $req = new $classname;
        $req->setFields("num_iid ,rated_nick,nick,created,item_title,item_price,content");
        $req->setRateType("get");
        $req->setRole("buyer");
		$req->setResult("good");
		$req->setPageNo($setPageNo);
		$req->setPageSize($setPageSize);
        return $resp = $c->execute($req, $sessionKey);
    }

    public function api_ItemGetReques($classname, $fields = "item_img", $proid, $sessionKey = null) {//根据商品id获取相应信息
        $c = $this->get_topobj($classname);
        $req = new $classname;
        $req->setFields($fields);
        $req->setNumIid($proid);
        return $resp = $c->execute($req);
    }

    //订购关系查询http://api.taobao.com/apidoc/api.htm?spm=0.0.0.33.dac0e6&path=cid:10124-apiId:10586
    public function api_VasSubscribeGetRequest($classname, $nickname, $article_code, $sessionKey = null) {
        $c = $this->get_topobj($classname);
        $req = new $classname;
        $req->setNick($nickname);
        $req->setArticleCode($article_code);
        return $resp = $c->execute($req);
    }

}

/* End of file Someclass.php */